-- dofile("luanames.lua")
-- x, vx, mass, rho, p, u, itype, hsml, ntotal = input()
-- 初始化2维剪切腔体的流体实粒子
function region()
    local x = {} -- loc
    local vx = {} -- vel
    local mass = {} -- mass
    local rho = {} -- rho
    local p = {} -- pressure
    local u = {} -- internal energy
    local itype = {} -- type

    local m = 41
    local n = 81
    local mp = m - 1
    local np = n - 1
    local ntotal = mp * np
    local nvirt = ntotal

    local xl = 1.0 / 2
    local yl = 1.0
    local dx = xl / mp -- hsml
    local dy = yl / np

    -- 初始化多维数组
    x[1] = {}
    x[2] = {}
    vx[1] = {}
    vx[2] = {}

    for i = 1, mp, 1 do
        for j = 1, np, 1 do
            local k = j + (i - 1) * np
            x[1][k] = (i - 1) * dx + dx * 2
            x[2][k] = (j - 1) * dy + dy * 2
        end
    end

    for i = 1, ntotal, 1 do
        vx[1][i] = 0.0
        vx[2][i] = 0.0
        p[i] = 0.0
        rho[i] = 1000.0
        mass[i] = dx * dy * rho[i]
        u[i] = 357.1
        itype[i] = 2 -- 淡水
    end

    -- 初始化虚粒子
    -- 下边界
    for i = 1, 8 * mp + 1 do
        nvirt = nvirt + 1
        x[1][nvirt] = (i - 1) * dx / 2
        x[2][nvirt] = 0.0 -- dx / 2 * (j - 1)
        vx[1][nvirt] = 0.0
        vx[2][nvirt] = 0.0
    end

    -- 左边界
    for i = 1, 6 * mp - 1 do
        -- for j = 1, 3, 1 do
        nvirt = nvirt + 1
        x[1][nvirt] = 0.0
        x[2][nvirt] = i * dx / 2
        vx[1][nvirt] = 0.0
        vx[2][nvirt] = 0.0
        -- end
    end

    -- 右边界
    for i = 1, 6 * mp - 1 do
        -- for j = 1, 3, 1 do
        nvirt = nvirt + 1
        x[1][nvirt] = yl * 2 -- + dx / 2 * (j - 1)
        x[2][nvirt] = i * dx / 2
        vx[1][nvirt] = 0.0
        vx[2][nvirt] = 0.0
        -- end
    end

    -- 上边界
    for i = 1, 8 * mp - 1 do
        nvirt = nvirt + 1
        x[1][nvirt] = i * dx / 2
        x[2][nvirt] = yl * 1.5 -- + dy / 2 * (j - 1)
        vx[1][nvirt] = 0.0
        vx[2][nvirt] = 0.0
    end

    for i = ntotal + 1, nvirt do
        p[i] = 0.0
        rho[i] = 1000.0
        mass[i] = dx * dy * rho[i]
        u[i] = 0.0
        itype[i] = -2 -- 虚粒子淡水
    end

    return x, vx, mass, rho, p, u, itype, dx, ntotal, nvirt - ntotal

end
